--[[/**
 * 阿莉克希亚 大招 平均回复
-- *
-- */]]

---@class BuffEffect392100 : BaseBuffEffect
BuffEffect392100 = ClientFight.CreateClass("BuffEffect392100", ClientFight.BaseBuffEffect)
local t = BuffEffect392100
t.BUFF_EFFECT_392100_FIGHTER_AMOUNT = "BUFF_EFFECT_392100_FIGHTER_AMOUNT";
---@param fight Fight
---@param buff FighterBuff
function t:add(fight, buff)
    local fighter = buff.target;
    local source = buff.source;
    local fightTeam = fight.teams[fighter.teamIndex];
    local peopleAmount = 0;

    local effectValues = buff.buffBean.f_BuffEffectValue;
    local shape = Rectangle2.New(effectValues[1], effectValues[2]);
    local targets = {};
    for k, f in pairs(fightTeam.fighters) do
        if (f:isSummons() and not f.isRealSummons()) then
            goto continue;
        end
        if (f:isDie()) then
            goto continue;
        end
        if (not DistanceUtil.overlap(fighter.position, shape, f.position, f.shape)) then
            goto continue;
        end
        table.insert(targets, f);
        peopleAmount = peopleAmount + 1;
        :: continue ::
    end
    local logPeopleAmount = peopleAmount;
    source.parametersByObject[t.BUFF_EFFECT_392100_FIGHTER_AMOUNT] = peopleAmount;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s  Buff%s 大招平均回复,有%s人",
            fight.frame, fighter.fighterId, buff.modelId, logPeopleAmount
    ));

    for k, f in pairs(targets) do
        BuffManager.addBuff(fight, buff.skill, source, f, false, effectValues[2], 1);
    end ;

    return ClientFight.BaseBuffEffect.add(self, fight, buff);

end

t.New()